package com.example.demo.service.impl;

import com.example.demo.entity.Report;
import com.example.demo.mapper.InfoMapper;
import com.example.demo.entity.Info;
import com.example.demo.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InfoServiceImpl implements InfoService {

    @Autowired
    private InfoMapper Infomapper;/*返回方法建议是返回值的全小写或首字母小写*/

    @Override
    public List<Info> findAllInfo() {
        //System.out.println("start"+System.currentTimeMillis());/*记录时间日志*/
        List<Info> Infos=Infomapper.findAllInfo();
        //System.out.println("end"+System.currentTimeMillis());/*记录时间日志*/
        return Infos;
    }

    @Override
    public List<Info> findAllInfo_Username(String s_username) {
        //System.out.println("start"+System.currentTimeMillis());/*记录时间日志*/
        List<Info> Infos=Infomapper.findAllInfo_Username(s_username);
        //System.out.println("end"+System.currentTimeMillis());/*记录时间日志*/
        return Infos;
    }

    @Override
    public Info findAInfo(int s_id) {
        //System.out.println("start"+System.currentTimeMillis());/*记录时间日志*/
        Info Infos=Infomapper.findAInfo(s_id);
        //System.out.println("end"+System.currentTimeMillis());/*记录时间日志*/
        return Infos;
    }

    @Override
    public int deleteAInfo(int s_id) {
        //System.out.println("start"+System.currentTimeMillis());/*记录时间日志*/
        int Infos=Infomapper.deleteAInfo(s_id);
        //System.out.println("end"+System.currentTimeMillis());/*记录时间日志*/
        return Infos;
    }

    @Override
    public int insertAInfo(Info Info) {
        //System.out.println("start"+System.currentTimeMillis());/*记录时间日志*/
        int Infos=Infomapper.insertAInfo(Info);
        //System.out.println("end"+System.currentTimeMillis());/*记录时间日志*/
        return Infos;
    }

    @Override
    public int updateAInfo(Info info) {
        int infos = Infomapper.updateAInfo(info);
        return infos;

    }

    @Override
    public int insertAReport(Report report) {
        int i;
        i=Infomapper.insertAReport(report);
        return i;
    }

    @Override
    public List<Info> matchTitle(String title) {
        List<Info> info = Infomapper.matchTitle(title);
        return info;
    }

    @Override
    public String findUserByInfoid(int id) {
        String username = Infomapper.findUserByInfoid(id);
        return username;
    }
}
